package lamma.lab.job;

import static junit.framework.Assert.assertEquals;

import java.util.concurrent.ExecutionException;

import org.junit.Test;

@Deprecated
public class ContextRunnerSingleSyncJob {

	private static class Job1 {
		
		@SuppressWarnings("unused")
		private String a;
		
		@SuppressWarnings("unused")
		private String b;

		private String result;
		
		@SuppressWarnings("unused")
		public Job1(String a, String b) {
			super();
			this.a = a;
			this.b = b;
		}
		
		@SuppressWarnings("unused")
		public void unexpectedCall() {
			throw new RuntimeException("not supposed to execute");
		}
		
		@SuppressWarnings("unused")
		@Step(serial=1)
		public void fetch() {
			
		}
		
		@SuppressWarnings("unused")
		@Step(serial=2)
		public void compile() throws InterruptedException, ExecutionException {
			result = "http://www.google.com";
		}

		@SuppressWarnings("unused")
		public String getResult() {
			return result;
		}

		@SuppressWarnings("unused")
		public void setResult(String result) {
			this.result = result;
		}
	}
	
	private class TestContext {
		
		@SuppressWarnings("unused")
		String input1;
		
		@SuppressWarnings("unused")
		String input2;
		
		@SuppressWarnings("unused")
		String input3;
		
		@FeedBy(job=Job1.class, params={"input1", "input2"}, result="result")
		String result1;

		public TestContext(String input1, String input2, String input3) {
			super();
			this.input1 = input1;
			this.input2 = input2;
			this.input3 = input3;
		}
	}
	
	@Test
	public void test() {
		TestContext c = new TestContext("iiiii1", "iiiii2", "iiiii3");
		
		ContextRunner runner = new ContextRunner();
		runner.run(c);
		
		assertEquals("http://www.google.com", c.result1);
	}
}

